package com.tanhua.server.controller;

import com.tanhua.domain.db.Settings;
import com.tanhua.domain.db.UserInfo;
import com.tanhua.server.service.SettingsService;
import com.tanhua.server.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
@RequestMapping("/users")
public class SettingController {

//    GET/users/settings

    @Autowired
    private SettingsService settingsService;

    @GetMapping(value = "/settings" ,name = "查询当前登录人的通用设置数据")
    public ResponseEntity querySettings(){

        return settingsService.querySettings();

    }
//    POST/users/questions/
    @PostMapping(value = "/questions" ,name = "保存陌生人问题")
    public ResponseEntity saveQuestions(@RequestBody Map map){
        String content = (String) map.get("content");
        return settingsService.saveQuestions(content);

    }

    //   路径：POST/users/notifications/setting
    @PostMapping(value = "/notifications/setting" ,name = "保存通知设置")
    public ResponseEntity saveSetting(@RequestBody Map map){
        Boolean likeNotification = (Boolean) map.get("likeNotification");
        Boolean pinglunNotification = (Boolean) map.get("pinglunNotification");
        Boolean gonggaoNotification = (Boolean) map.get("gonggaoNotification");

        return settingsService.saveSetting(likeNotification,pinglunNotification,gonggaoNotification);

    }



    @GetMapping(value = "/blacklist" ,name = "查询用户的黑名单数据")
    public ResponseEntity queryBlacklist(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10")Integer pagesize){
        return settingsService.queryBlacklist(page,pagesize);

    }

//    DELETE/users/blacklist/:uid
    @DeleteMapping(value = "/blacklist/{uid}" ,name = "删除黑名单数据")
    public ResponseEntity deleteBlacklist(@PathVariable("uid") Long blacklistId){
        return settingsService.deleteBlacklist(blacklistId);

    }


}
